package com.easylive.web.controller;

import java.util.List;

import com.easylive.web.entity.query.UserInfoQuery;
import com.easylive.web.entity.po.UserInfo;
import com.easylive.web.entity.vo.ResponseVO;
import com.easylive.web.service.UserInfoService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author c.w
 * @description 用户信息业务
 * @date 15:24 2025/3/27
 **/
@RestController("userInfoController")
@RequestMapping("/userInfo")
public class UserInfoController extends ABaseController {

    @Resource
    private UserInfoService userInfoService;

    /**
     * 根据条件分页查询
     */
    @RequestMapping("/loadDataList")
    public ResponseVO loadDataList(UserInfoQuery query) {
        return getSuccessResponseVO(userInfoService.findListByPage(query));
    }

    /**
     * 新增
     */
    @RequestMapping("/add")
    public ResponseVO add(UserInfo bean) {
        userInfoService.add(bean);
        return getSuccessResponseVO(null);
    }

    /**
     * 批量新增
     */
    @RequestMapping("/addBatch")
    public ResponseVO addBatch(@RequestBody List<UserInfo> listBean) {
        userInfoService.addBatch(listBean);
        return getSuccessResponseVO(null);
    }

    /**
     * 批量新增/修改
     */
    @RequestMapping("/addOrUpdateBatch")
    public ResponseVO addOrUpdateBatch(@RequestBody List<UserInfo> listBean) {
        userInfoService.addBatch(listBean);
        return getSuccessResponseVO(null);
    }

    /**
     * 根据UserId查询对象
     */
    @RequestMapping("/getUserInfoByUserId")
    public ResponseVO getUserInfoByUserId(String userId) {
        return getSuccessResponseVO(userInfoService.getUserInfoByUserId(userId));
    }

    /**
     * 根据UserId修改对象
     */
    @RequestMapping("/updateUserInfoByUserId")
    public ResponseVO updateUserInfoByUserId(UserInfo bean, String userId) {
        userInfoService.updateUserInfoByUserId(bean, userId);
        return getSuccessResponseVO(null);
    }

    /**
     * 根据UserId删除
     */
    @RequestMapping("/deleteUserInfoByUserId")
    public ResponseVO deleteUserInfoByUserId(String userId) {
        userInfoService.deleteUserInfoByUserId(userId);
        return getSuccessResponseVO(null);
    }

    /**
     * 根据Email查询对象
     */
    @RequestMapping("/getUserInfoByEmail")
    public ResponseVO getUserInfoByEmail(String email) {
        return getSuccessResponseVO(userInfoService.getUserInfoByEmail(email));
    }

    /**
     * 根据Email修改对象
     */
    @RequestMapping("/updateUserInfoByEmail")
    public ResponseVO updateUserInfoByEmail(UserInfo bean, String email) {
        userInfoService.updateUserInfoByEmail(bean, email);
        return getSuccessResponseVO(null);
    }

    /**
     * 根据Email删除
     */
    @RequestMapping("/deleteUserInfoByEmail")
    public ResponseVO deleteUserInfoByEmail(String email) {
        userInfoService.deleteUserInfoByEmail(email);
        return getSuccessResponseVO(null);
    }

    /**
     * 根据NickName查询对象
     */
    @RequestMapping("/getUserInfoByNickName")
    public ResponseVO getUserInfoByNickName(String nickName) {
        return getSuccessResponseVO(userInfoService.getUserInfoByNickName(nickName));
    }

    /**
     * 根据NickName修改对象
     */
    @RequestMapping("/updateUserInfoByNickName")
    public ResponseVO updateUserInfoByNickName(UserInfo bean, String nickName) {
        userInfoService.updateUserInfoByNickName(bean, nickName);
        return getSuccessResponseVO(null);
    }

    /**
     * 根据NickName删除
     */
    @RequestMapping("/deleteUserInfoByNickName")
    public ResponseVO deleteUserInfoByNickName(String nickName) {
        userInfoService.deleteUserInfoByNickName(nickName);
        return getSuccessResponseVO(null);
    }
}